import { ref } from "vue";
export default {
    setup() {
        const dialogVisible = ref(false);
        const callback = ref(undefined)
        const loading = ref(false);
        function close(data) {
            if (typeof callback.value === 'function') {
                loading.value = true;
                callback(data);
                loading.value = false;
            }
            dialogVisible.value = false;
            destroyed();
        }
        function closeSilence() {
            dialogVisible.value = false;
            destroyed();
        }
        // 删除dom节点
        function destroyed() {
            // if appendToBody is true, remove DOM node after destroy
            if (this.$el && this.$el.parentNode) {
                this.$el.parentNode.removeChild(this.$el);
            }
        }
        return {
            close,
            closeSilence,
            destroyed
        }
    }
}
